package com.example.jiaju.ui;

import static android.content.Context.MODE_PRIVATE;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;

import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.example.jiaju.LoginActivity;
import com.example.jiaju.R;
import com.example.jiaju.ui.my.*;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;

/**
 * 我的页面
 */
public class MyFragment extends Fragment {


    private CollapsingToolbarLayout collapsingToolbarLayout;
    private AppBarLayout appBarLayout;
    private Toolbar toolbar;
    private ImageView myCollect;




    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.fragment_my, container, false);

        ImageView imageView=view.findViewById(R.id.leave);
        myCollect=view.findViewById(R.id.my_collect);

        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SharedPreferences sp = getActivity().getSharedPreferences("user",MODE_PRIVATE);
                SharedPreferences.Editor editor=sp.edit();
                editor.putBoolean("isLogin",false).commit();
                Intent intent=new Intent(getActivity(), LoginActivity.class);
                startActivity(intent);
            }
        });
        myCollect.setOnClickListener(v->{
            Intent intent=new Intent(getActivity(), CollectionActivity.class);
            startActivity(intent);
        });
      return view;
    }

//    //返回按钮，监听android.R.id.home
//    @Override
//    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
//        switch (item.getItemId()){
//            case android.R.id.home:
//                getActivity().finish();
//                return true;
//        }
//        return super.onOptionsItemSelected(item);
//    }





}